package com.zdp.sources.resource;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author sesshomaru
 * @date 2022/2/28
 */
@Configuration
@ConfigurationProperties(prefix = "custom")
public class CustomProperties {

    @Getter
    @Setter
    private Db db = new Db();

    @Getter
    @Setter
    public static class Db {
        private BasisHikariDateSource master1 = new BasisHikariDateSource();
        private BasisHikariDateSource slave1 = new BasisHikariDateSource();
        private BasisHikariDateSource slave2 = new BasisHikariDateSource();
    }

    @Getter
    @Setter
    public static class BasisHikariDateSource{
        private String jdbcUrl = "jdbc:mysql://localhost:3306/test?useAffectedRows=true&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&serverTimezone=UTC&useSSL=false&verifyServerCertificate=false&autoReconnct=true&autoReconnectForPools=true&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull";
        private String username = "root";
        private String password = "root";
        private Long connectionTimeout = 30000L;
        private Integer minimumIdle = 5;
        private Integer maximumPoolSize = 20;
        private Boolean autoCommit = true;
        private Long idleTimeout = 600000L;
        private String poolName = "DateSourceHikariCP-1";
        private Long maxLifetime = 1800000L;
        private String connectionTestQuery = "SELECT 1";
    }

}
